package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.RTbMerchantServiceTransactionRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.TbMerchantServiceTransactionRecord;
import com.ruoyi.system.service.ITbMerchantServiceTransactionRecordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 商家交易订单Controller
 * 
 * @author lzd
 * @date 2024-09-10
 */
@RestController
@RequestMapping("/transactionRecord")
public class TbMerchantServiceTransactionRecordController extends BaseController
{
    @Autowired
    private ITbMerchantServiceTransactionRecordService tbMerchantServiceTransactionRecordService;

    /**
     * 查询商家交易订单列表关联状态字典
     */
//    @RequiresPermissions("system:transactionRecord:list")
    @GetMapping("/list")
    public TableDataInfo list(RTbMerchantServiceTransactionRecord rTbMerchantServiceTransactionRecord)
    {
        startPage();
        List<RTbMerchantServiceTransactionRecord> list = tbMerchantServiceTransactionRecordService.selectRTbMerchantServiceTransactionRecordList(rTbMerchantServiceTransactionRecord);
        return getDataTable(list);
    }

    /**
     * 查询商家交易订单列表
     */
//    @RequiresPermissions("system:transactionRecord:list")
//    @GetMapping("/list")
//    public TableDataInfo list(TbMerchantServiceTransactionRecord tbMerchantServiceTransactionRecord)
//    {
//        startPage();
//        List<TbMerchantServiceTransactionRecord> list = tbMerchantServiceTransactionRecordService.selectTbMerchantServiceTransactionRecordList(tbMerchantServiceTransactionRecord);
//        return getDataTable(list);
//    }

    /**
     * 导出商家交易订单列表
     */
    @RequiresPermissions("system:transactionRecord:export")
    @Log(title = "商家交易订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbMerchantServiceTransactionRecord tbMerchantServiceTransactionRecord)
    {
        List<TbMerchantServiceTransactionRecord> list = tbMerchantServiceTransactionRecordService.selectTbMerchantServiceTransactionRecordList(tbMerchantServiceTransactionRecord);
        ExcelUtil<TbMerchantServiceTransactionRecord> util = new ExcelUtil<TbMerchantServiceTransactionRecord>(TbMerchantServiceTransactionRecord.class);
        util.exportExcel(response, list, "商家交易订单数据");
    }

    /**
     * 获取商家交易订单详细信息
     */
    @RequiresPermissions("system:transactionRecord:query")
    @GetMapping(value = "/{transactionId}")
    public AjaxResult getInfo(@PathVariable("transactionId") Long transactionId)
    {
        return success(tbMerchantServiceTransactionRecordService.selectTbMerchantServiceTransactionRecordByTransactionId(transactionId));
    }

    /**
     * 新增商家交易订单
     */
    @RequiresPermissions("system:transactionRecord:add")
    @Log(title = "商家交易订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbMerchantServiceTransactionRecord tbMerchantServiceTransactionRecord)
    {
        return toAjax(tbMerchantServiceTransactionRecordService.insertTbMerchantServiceTransactionRecord(tbMerchantServiceTransactionRecord));
    }

    /**
     * 修改商家交易订单
     */
    @RequiresPermissions("system:transactionRecord:edit")
    @Log(title = "商家交易订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbMerchantServiceTransactionRecord tbMerchantServiceTransactionRecord)
    {
        return toAjax(tbMerchantServiceTransactionRecordService.updateTbMerchantServiceTransactionRecord(tbMerchantServiceTransactionRecord));
    }

    /**
     * 删除商家交易订单
     */
    @RequiresPermissions("system:transactionRecord:remove")
    @Log(title = "商家交易订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{transactionIds}")
    public AjaxResult remove(@PathVariable Long[] transactionIds)
    {
        return toAjax(tbMerchantServiceTransactionRecordService.deleteTbMerchantServiceTransactionRecordByTransactionIds(transactionIds));
    }
}
